<?php
/**
 * Created by JetBrains PhpStorm.
 * User: Mihail Markitan
 * Date: 10/30/11
 * Time: 9:02 PM
 */
 ?>
<?php 
switch ($model->pricecode) {
    case 'A':
        $itemPriceCode = 'pricea';
        break;
    case 'B':
        $itemPriceCode = 'priceb';
        break;
   case 'C':
       $itemPriceCode = 'pricec';
        break; 
    default :  $itemPriceCode = 'pricea';
    
}
$taxcode = Taxcodes::model()->findByPk($model->taxcode);
$taxcode = json_encode($taxcode->attributes);
?>
<?php Yii::app()->clientScript->registerScript('taxcode',"taxcode=$taxcode",  CClientScript::POS_HEAD); ?>
<?php Yii::app()->clientScript->registerScript('itemPriceCode',"itemPriceCode='$itemPriceCode'",  CClientScript::POS_HEAD); ?>
<?php Yii::app()->clientScript->registerScript('custno',"custno='$customer->custno'",  CClientScript::POS_HEAD); ?>
<?php Yii::app()->clientScript->registerScript('invoice',"invoice='$model->invoice'; ",  CClientScript::POS_HEAD); ?>
<?php Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl.'/js/app/invoicetechnician.js',CClientScript::POS_BEGIN);?>
<?php Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl.'/js/app/invoicesItems.js',CClientScript::POS_BEGIN);?>
<?php Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl.'/js/app/invoicesFunctions.js',CClientScript::POS_BEGIN);?>
<?php Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl.'/js/app/invoiceupdate.js',CClientScript::POS_BEGIN);?>
<div id="left-col">
    
    <?php $this->renderPartial('_side',array(
        'location'=>$location,
        'customer'=>$customer,
        'action'=>'update',
        'model'=>$model
    ))?>


</div>


<div id="right-col">

    <div class="wrap">
        <div class="container">


            <div id="breadcrumb" style="display:none;"><span style="padding-left:10px;font-size:10px;color:#777777;" id="alsoviewing"></span></div>
            <div class="inside">

                <h1>Create invoice for :</h1>

               <?php
                $this->renderPartial('_view',array('location'=>$location,
                                                    'customer'=>$customer
                                                     ))
                ?>
                 <?php $this->renderPartial('_form',array('location'=>$location, 'model'=>$model)) ?>

 <br/>
                <ul id="tab" class="tabs tabs-with-summary">
                    <li class="active"><a href="#invoice">Invoice</a></li>
                    <li><a href="#technician">Technician</a></li>
                    <li><a href="#equipment">Equipment</a></li>
                    <li><a href="#document">Document</a></li>
                </ul>
                
                <br/>   
                <div id="invoice">
                    <a href="javascript:void(0)" id="createItem" class="add-button">Add Item</a>
                    <div id="item-list">
                        
                    </div>
                </div>
                <div id="technician">
                    <a href="javascript:void(0)" id="createTechnician" class="add-button">Add Technician</a>
                    <div id="emp-list"></div>
                </div>
                <div id="equipment"></div>
                <div id="document"></div>

  <div class="row">
        <table id="summarytable">


            <tr>

          
                 <td style="display: block;margin: 10px;float:right;  width: auto;">
                     <span style="text-align: left;"> Subtotal&nbsp;</span> <span style="float: right;" id="subtotal"></span> <br/>
                    <span style="text-align: left;">Tax</span> <span style="float: right;" id ="taxtotal"></span><br>
                    <span style="text-align: left;">Total</span> : <span id ="total" style="float: right;">0.00</span>
                </td>
                <td style="display: block; margin: 10px;float:right;  width: auto; ">
                    <span style="text-align: left; ">Material cost&nbsp; </span> <span style="float: right;" id="materialcost">0.00</span></span></br>
                    <span style="text-align: left; ">Labor cost</span><span id="laborcost" style="float: right; "></span></br>
                    <span style="text-align: left; ">Other cost </span> <span style="float: right;">0.00</span></br>
                </td>


            </tr>

        </table>
    </div>






            </div><!-- inside -->
        </div><!-- container -->
    </div><!-- wrap -->
    <?php $this->renderPartial('application.views.copyright'); ?>
</div> <!-- left-col -->
